package com.seari.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.seari.bean.FlowText;
import com.seari.bean.RightLineGuardPoint;
import com.seari.pojo.MessageBean;
import com.seari.service.RightLineGuardPointService;
import com.seari.utils.HandlerNullUtils;

/**
 * 正线值守点
 * 小电科数据
 * @author liuqi
 *
 */
@RestController
public class RightLineGuardPointController {
	
	@Autowired
	private RightLineGuardPointService rightLineGuardPointService;
	
	/**
	 *
	 * 值守点专业查询
	 */
	@RequestMapping(value = "/fault/getGuardPointProfession")
	@ResponseBody
	public MessageBean getGuardPointProfession(){

		MessageBean messageBean = new MessageBean();
		try {
			
			List<Map<String, Object>> guardPoint = rightLineGuardPointService.getGuardPointProfession();
			messageBean.setType("success");
			messageBean.setCode("1000");
			messageBean.setMessage("值守点专业获取成功 ");
			messageBean.setData(guardPoint);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setCode("3000");
			messageBean.setMessage("值守点专业获取失败");
		}

		return messageBean;

	}
	
	/**
	 * 正线值守点线路信息
	 * @return
	 */
	@RequestMapping(value = "/fault/getGuardPointLineInfo")
	@ResponseBody
	public MessageBean getGuardPointLineInfo(){

		MessageBean messageBean = new MessageBean();
		try {
			
			List<String> line = rightLineGuardPointService.getGuardPointLineInfo();
			messageBean.setType("success");
			messageBean.setCode("1000");
			messageBean.setMessage("正线值守点线路信息获取成功 ");
			messageBean.setData(line);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setCode("3000");
			messageBean.setMessage("正线值守点线路信息获取失败");
		}

		return messageBean;

	}
	
	/**
	 *
	 * 获取正线值守点信息
	 */
	@RequestMapping(value = "/fault/getRightLineGuardPointInfoList")
	@ResponseBody
	public MessageBean getRightLineGuardPointInfoList(@RequestBody Map<String, Object> map){

		MessageBean messageBean = new MessageBean();
		try {
			Map<String,Object> mapInMap = new HashMap<String,Object>();
			if(!HandlerNullUtils.objectIsNull(map.get("line"))) {
				String line = (String) map.get("line");
				mapInMap.put("line", line);
			}
			if(!HandlerNullUtils.objectIsNull("zy")) {
				String zy = (String) map.get("zy");
				mapInMap.put("zy",zy);
			}
			
			List<RightLineGuardPoint> guardPoint = rightLineGuardPointService.getRightLineGuardPointInfoList(mapInMap);
			messageBean.setType("success");
			messageBean.setCode("1000");
			messageBean.setMessage("值守点信息获取成功 ");
			messageBean.setData(guardPoint);
		} catch (Exception e) {
			e.printStackTrace();
			messageBean.setType("fail");
			messageBean.setCode("3000");
			messageBean.setMessage("值守点信息获取失败");
		}

		return messageBean;

	}
	
}
